package com.mrjy.activity.controller;

import java.util.HashMap;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrjy.activity.bo.IActivityApplyInfoBo;
import com.mrjy.activity.dto.ActivityApplyDTOMap;
import com.mrjy.common.entity.ActivityApplyInfo;
import com.mrjy.common.entity.UserInfo;
import com.mrjy.common.enums.ResultEnum;
import com.mrjy.common.util.GlobalConstant;

@Controller
@RequestMapping("/activityapply")
public class ActivityApplyInfoController {
	@Resource 
	private IActivityApplyInfoBo activityApplyBo;
	/**
	 * 分页查询活动报名列表 后台
	 * @return
	 */
	@RequestMapping(value="/back/selectActivityApplyList")
	@ResponseBody
	public Object selectActivityApplyList(ActivityApplyInfo activityApplyInfo,HttpSession session) {
		UserInfo loginUser = (UserInfo) session.getAttribute(GlobalConstant.USER_INFO);
		if(null == loginUser ){
			HashMap<String, Object> map = new HashMap<String,Object>();
			map.put("err_code", ResultEnum.NOT_LOGIN.getMessage());
			return map;
		}
		return activityApplyBo.selectActivityApplyList(activityApplyInfo);
	}
	/**
	 * 微信端报名成功跳转信息填写
	 * */
	@RequestMapping("/insertActivityApplyInfo")
	@ResponseBody
	public Object insertActivityApplyInfo(ActivityApplyInfo activityApplyInfo,HttpSession session){
		return activityApplyBo.insertActivityApplyInfo(activityApplyInfo, session);
	}
	/**
	 * 导出活动管理用户报名信息
	 **/
	@RequestMapping("/back/exportActivityApplyInfo")
	@ResponseBody
	public Object exportActivityApplyInfo(ActivityApplyDTOMap selectDTO,HttpSession session,HttpServletResponse response){
		UserInfo loginUser = (UserInfo) session.getAttribute(GlobalConstant.USER_INFO);
		if(null == loginUser ){
			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put("err_msg", ResultEnum.NOT_LOGIN.getMessage());
			return map;
		}
		return activityApplyBo.exportActivityApplyInfo(selectDTO,response);
	}
	
	@RequestMapping("/detail")
	@ResponseBody
	public Object selectByActPayId(ActivityApplyInfo info){
		return activityApplyBo.selectByActPayId(info);
	}
	
	@RequestMapping("/edit")
	@ResponseBody
	public Object edit(ActivityApplyInfo info){
		return activityApplyBo.txUpdateById(info);
	}
	
}
